package ntu.khpi.eim30.project.x;

import java.awt.Color;

public class PhotoCode {

	public static PictureN code(PictureN image, String codeByte, int stepByte) {
		LiFSR codeRandom = new LiFSR(codeByte, stepByte);
		int widthPicture = image.width();
		int heightPicture = image.height();
		int redColor;
		int greenColor;
		int blueColor;
		for (int i = 0; i < widthPicture; i++) {
			for (int j = 0; j < heightPicture; j++) {

				Color colorPixel = image.get(i, j);// Return the color of pixel
													// (i, j).

				redColor = colorPixel.getRed();
				int newRedColor = codeRandom.generate(8);
				redColor = redColor ^ newRedColor;

				greenColor = colorPixel.getGreen();
				int newGreenColor = codeRandom.generate(8);
				greenColor = greenColor ^ newGreenColor;

				blueColor = colorPixel.getBlue();
				int newBlueColor = codeRandom.generate(8);
				blueColor = blueColor ^ newBlueColor;

				Color colorPicture = new Color(redColor, greenColor, blueColor);
				image.set(i, j, colorPicture);
			}

		}
		return image;
	}

}
